import React, { useContext } from 'react';
import { ConfigProvider, Transfer as AntdTransfer } from 'antd';
import type { TransferProps as AntdTransferProps } from 'antd';

import { useTransferStyles } from './style';
import { transferThemeConfig } from '../../themes/transfer';

// 导出样式扩展 Hook，方便用户使用特殊效果
export { useTransferStyles } from './style';

export interface TransferProps extends AntdTransferProps {
  // 继承所有 antd Transfer 属性，无需额外属性
}

const Transfer: React.FC<TransferProps> = ({ 
  className,
  ...restProps 
}) => {
  const { styles, cx } = useTransferStyles();
  const context = useContext(ConfigProvider.ConfigContext);
  
  // 合并样式：基础样式 + 用户样式
  const transferClassName = cx(
    styles.enhancedTransfer,      // 基础样式增强
    className                     // 用户自定义样式
  );

  return (
    <ConfigProvider
      theme={{
        components: {
          Transfer: {
            ...transferThemeConfig,
            ...context?.theme?.components?.Transfer,
          },
        },
      }}
    >
      <AntdTransfer 
        className={transferClassName} 
        {...restProps} 
      />
    </ConfigProvider>
  );
};

export { Transfer };
export default Transfer;

